package com.eportal.action.background;

import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.eportal.action.BaseAction;
import com.eportal.aop.LogAnnotation;
import com.eportal.domain.Sysopt;
import com.eportal.domain.Sysroles;
import com.eportal.domain.SysrolesTemplate;
import com.eportal.service.SysRolesService;
import com.eportal.service.SysRolesTemplateService;
import com.eportal.util.ValidateUtil;
import com.opensymphony.xwork2.ModelDriven;

/**
 * 角色管理
 * @author chencheng
 *
 */
public class RoleTemplateAction extends BaseAction implements ModelDriven<SysrolesTemplate> {

    private static Logger log = Logger.getLogger(RoleTemplateAction.class.getName());

    private Map<String, Object> result = new HashMap<String, Object>();

    @Autowired
    private SysRolesTemplateService sysRolesTemplateService;
    
    
    
    /**
     * 角色模板管理
     */
    public String listModelView() {
        return SUCCESS;
    }
    

	/**
     * 角色模板列表
     */
    public void listModel() throws Exception {
        List<SysrolesTemplate> sysrolesTemplate = sysRolesTemplateService.list();
        responseBody(sysrolesTemplate);
    }
    

    /**
     * 角色模板修改
     */
    public String editModelView() {
    	SysrolesTemplate role = sysRolesTemplateService.get(getModel().getSid());
        getRequest().setAttribute("role", role);
        return SUCCESS;
    }
    
    /**
     * 角色模板修改保存
     */
    public void update(){
    	SysrolesTemplate sysrolesTemplatee = getModel();
    	result = sysRolesTemplateService.updateMethod(sysrolesTemplatee);
        responseBody(result);
    }
    		
   


    private SysrolesTemplate sysrolesTemplate = new SysrolesTemplate();

    @Override
    public SysrolesTemplate getModel() {
        return sysrolesTemplate;
    }
}
